@import (reference) 'config';
@import (reference) 'icons';
@import (reference) '../../app/less/typography';

@dex-lower-block-height: 50%;

body.dex,
body.dex-demo {
  color: @color-basic-900;

  .dex-wrapper {
    width: 100%;
    height: 100%;

    .block-title {
      .w-input-wrap input {
        padding: 6px 8px 6px 21px;
        background: url(/img/icons/icon-search-dex.svg) 0 center no-repeat;
        background-size: 12px 12px;
        font-size: @font-size-caption-2;
        height: 29px;
        border: 0 none;
        border-radius: 0;
        width: 100%;
      }

      .has-search {
        width: 50%;
        margin-left: 20px;
        position: relative;

        &::before {
          width: 1px;
          height: 37px;
          content: '';
          background: @color-basic-100;
          display: block;
          position: absolute;
          left: -10px;
          top: -4px;
        }
      }
    }

    .search-item {
      font-size: @font-size-caption-1;
      cursor: pointer;

      &.has-ticker {
        font-weight: bold;
      }
    }

    .input-clear {
      display: block;
      position: absolute;
      right: 1px;
      top: 50%;
      margin-top: -1px;
      transform: translateY(-50%);
      width: 30px;
      height: 30px;
      z-index: 2;
      cursor: pointer;
      background-image: url(/img/icons/order_cancel.svg);
      background-size: 8px 8px;
      background-repeat: no-repeat;
      background-position: center;
    }

    .smart-table {
      width: 100%;
      height: 100%;
      display: block;

      &__w-thead {
        //color: @dex-table-headers;
        color: @color-basic-600;
        border-bottom: 1px solid @color-basic-100;

        div {
          span {
            cursor: pointer;
          }
        }

        .smart-table {
          &__row {
            height: 28px;
            width: 100%;
            display: flex;
            align-items: center;
            font-size: @font-size-caption-2;
            padding: 0 14px;
          }

          &__cell {
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
          }
        }
      }

      &__row {
        font-size: @font-size-caption-2;
        display: flex;
        align-items: center;

        .cell-label {
          display: none;
          color: @color-basic-500;
          margin-right: 7px;
          font-size: @font-size-caption-2;
        }
      }

      &__cell {
        &[data-column-id="controls"] {
          color: @color-basic-700;
        }
      }

      &__cell:first-child {
        min-width: auto;
        padding-left: 0;
      }

      &__cell:last-child {
        padding-right: 0;
      }
    }
  }

  .dex-layout {
    &__tradehistory {
      w-tabs {

        ::-webkit-scrollbar {
          height: 0;
        }
        :hover::-webkit-scrollbar {
          height: 0;
        }
        ::-webkit-scrollbar-thumb {
          height: 0;
        }
        ::-webkit-scrollbar-thumb:window-inactive {
          height: 0;
        }

        .tab-tem {
          overflow-x: auto;
        }

        .tab-body-wrap {
          height: calc(100% ~'- 39px');
        }

        .titles-wrap {
          overflow-y: hidden;
          overflow-x: auto;
          height: 39px;
          padding: 0;
          display: flex;
          position: relative;

          &::before {
            display: none;
          }

          &:after {
            content: '';
            display: block;
            position: absolute;
            width: 100%;
            height: 1px;
            left: 0;
            bottom: 0;
            background: @color-basic-100;
          }

          .title {
            color: @color-basic-700;
            height: 38px;
            font-size: 13px;
            margin: 0;
            padding: 0 20px;
            line-height: 40px;
            border: 0 none;
            font-family: @font-roboto-medium;
            position: relative;
            border-left: 1px solid transparent;
            border-right: 1px solid transparent;
            white-space: nowrap;

            &.active:first-child {
              border-left: 1px solid @color-white;
            }

            &.active {
              color: @color-basic-700;
              background: @color-white;
              border-bottom: 1px solid @color-white;
              border-right: 1px solid @color-disabled-200;
              border-left: 1px solid @color-disabled-200;

              &::before {
                display: block;
                position: absolute;
                top: 0;
                left: 0;
                width: 100%;
                content: '';
                height: 2px;
                background: @color-submit-400;
              }

              &:after {
                position: absolute;
                bottom: -2px;
                height: 2px;
                width: 100%;
                left: 0;
                content: '';
                display: block;
                z-index: 1;
                background: @color-white;
              }
            }
          }
        }

        .tabs-myOrderHistory {
          .smart-table {
            &__cell {
              .decimal-muted {
                color: @color-basic-900;
              }
            }
          }
        }

        .smart-table {
          &__w-thead {
            z-index: 3;

            .smart-table {
              &__row {
                &:last-child {
                  margin-bottom: 0;
                }
              }

              &__cell {
                height: 28px;
                line-height: 28px;

                &[data-column-id="controls"] {
                  overflow: visible;
                }
              }
            }
          }

          &__w-tbody {
            .smart-table {
              &__row {
                a {
                  color: @color-disabled-900;
                }

                &:hover:not(.disabled) {
                  background-color: @dex-selected-item-bg;

                  .underline {
                    a {
                      display: inline-block;
                      position: relative;

                      &:after {
                        display: block;
                        height: 1px;
                        border-bottom: 1px dashed @color-basic-400;
                        position: absolute;
                        content: '';
                        bottom: 0;
                        width: 100%;
                      }
                    }
                  }
                }
              }
            }
          }

          .status {
            margin-top: 3px;
            .tag-3();

            .progress-bar {
              width: 100%;
              height: 2px;
              margin-top: 2px;

              .progress-fill {
                max-width: 100%;
                height: 2px;
              }
            }
          }

          // status and type colors
          &__row {

            &.buy {
              .smart-table {

                &__cell[data-column-id="pair"] {
                  span.status-mobile {
                    color: @color-submit-400;
                    background: @color-submit-50;
                  }
                }

                &__cell[data-column-id="type"],
                &__cell[data-column-id="status"] {
                  color: @color-submit-400;

                  .progress-bar {
                    background: @color-bluebar-400;

                    .progress-fill {
                      background: @color-bluebar-1000;
                    }
                  }
                }
              }
            }

            &.sell {
              .smart-table {

                &__cell[data-column-id="pair"] {
                  span.status-mobile {
                    color: @color-error-500;
                    background: @color-error-100;
                  }
                }

                &__cell[data-column-id="type"],
                &__cell[data-column-id="status"] {
                  color: @color-error-500;

                  .progress-bar {
                    background: @color-redbar-400;

                    .progress-fill {
                      background: @color-redbar-1000;
                    }
                  }
                }
              }
            }

            &.cancelled {
              color: @color-disabled-500;

              .progress-fill {
                display: none;
              }

              &.sell {
                .smart-table {
                  &__cell[data-column-id="type"],
                  &__cell[data-column-id="status"] {
                    color: @color-error-200;

                    .progress-bar {
                      background: @color-error-100;
                    }
                  }
                }
              }

              &.buy {
                .smart-table {
                  &__cell[data-column-id="type"],
                  &__cell[data-column-id="status"] {
                    color: @color-submit-200;

                    .progress-bar {
                      background: @color-submit-50;
                    }
                  }
                }
              }
            }

            .smart-table__cell {
              .cancelled {
                opacity: .5;
              }
            }
          }
          // end

          &__row {
            position: relative;
            display: flex;
            justify-content: space-between;

            .dropdown {
              display: none;
              cursor: pointer;
              width: 30px;
              height: 30px;
              position: absolute;
              right: 4px;
              top: 1px;
              background: url(/img/icons/dex-toggle.svg) center no-repeat;
              background-size: 10px;
            }
          }

          .order-row:last-child {
            margin-bottom: 10px;
          }

          &__cell {
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;

            .decimal-muted {
              color: @color-basic-500;
            }
          }
        }
      }
    }

    .order-permission-error,
    .create-order-notification {
      will-change: transform;
      position: absolute;
      transform: translate(0, -100%);
      color: @white-only;
      z-index: 10;
      width: 100%;
      padding: 10px 0;
      text-align: center;
      display: flex;
      justify-content: center;
      align-items: center;
      background-color: @color-submit-400;
      font-family: @font-roboto-medium;

      i.icon {
        margin-right: 5px;
        display: inline-block;
        width: 13px;
        height: 13px;
        vertical-align: middle;
      }

      &.success {
        background-color: @color-submit-400;
        i.icon {
          background: url(/img/icons/checkbox-icon.svg) no-repeat center center;
        }
      }

      &.error {
        background-color: @color-error-400;
        i.icon {
          background: url(/img/icons/white-cancel-icon.svg) no-repeat center center;
        }
      }
    }
  }

  w-dex-trade-graph {
    height: 100%;
    max-height: 100%;
    overflow: hidden;
  }

  .candle-chart-wrapper.error {
    display: flex;

    & > div {
      text-align: center;
      display: flex;
      margin: auto;

      div:first-child {
        .body-1();
        margin: 0 auto 5px auto;
        color: @color-basic-700;

        &::before {
          background-image: url(/img/icons/icon-empty.svg);
          background-repeat: no-repeat;
          width: 50px;
          height: 52px;
          margin: 0 auto 20px;
          display: block;
          content: '';
        }
      }

      div:last-child {
        color: @color-basic-500;
        padding: 0 140px;
      }

    }
  }

  input::placeholder {
    color: @color-basic-500;
    opacity: 1;
  }
}

@media screen and (max-width: 1024px) {
  body.dex, body.dex-demo {
    .main-content .content {
      height: 100%;
      width: 100%;
      padding: 5px;
      right: 0;
      bottom: 0;

      w-dex-candle-chart {
        border-radius: 0 0 2px 0;
      }

      w-tabs {

        .tab-body-wrap {
          height: calc(100% ~'- 48px');
        }

        .titles-wrap {
          height: 48px;
          box-shadow: @shadow-menu-top;
          position: relative;
          z-index: 6;

          &::after {
            display: none;
          }

          .title {
            height: 48px;
            line-height: 48px;

            &.active {
              border: 0 none;
              border-bottom: 1px solid @color-submit-400;

              &::after,
              &::before {
                display: none;
              }
            }
          }

        }

        .smart-table {
          &__w-tbody {

            .smart-table {
              &__row {
                position: relative;

                &:hover {
                  .underline:after {
                    display: none;
                  }
                }

                .status-mobile {
                  display: inline-block;
                }

                &.active {
                  .dropdown {
                    transform: rotate(180deg);
                  }

                  & + .active::before {
                    background: @color-basic-100;
                    height: 1px;
                    width: calc(100% ~'- 20px');
                    position: absolute;
                    top: 0;
                    left: 10px;
                    display: block;
                    content: '';
                  }
                }
              }
            }
          }

          &__cell {
            padding: 0;

            .dropdown {
              display: block;
            }
          }

        }
      }

      w-tabs,
      w-dex-watchlist {
        w-table {
          w-t-head {
            display: none;
          }
        }
      }
    }
  }
}

@media screen and (max-width: 659px) {

  body.dex, body.dex-demo {
    .main-content .content {
      width: 100%;
      padding: 5px;
      right: 0;
      bottom: 0;
      height: 100%;
      max-height: calc(100% ~' - 80px');
      overflow: auto;

      .dex-layout {
        &__tradehistory {

          w-dex-my-balance {
            .smart-table {
              &__w-tbody {
                max-height: 217px;
              }
            }
          }

          w-dex-trade-history {
            .smart-table {
              &__w-tbody {
                max-height: 243px;
              }

              &.my-trade-history {
                .smart-table {
                  &__w-tbody {
                    max-height: 255px;
                  }
                }
              }
            }
          }

          w-dex-my-orders {
            .smart-table {
              &__w-tbody {
                max-height: 254px;
              }
            }
          }

        }
      }

      .dex-wrapper {
        w-tabs {
          w-scroll-box {
            height: 392px;
            width: 100%;
            overflow-y: auto;
            overflow-x: hidden;
          }
        }
      }
    }
  }
}

w-dex-my-orders {
  .smart-table__cell[data-column-id="controls"] {
    flex-shrink: 0;
  }
}
